import { AxiosRequestConfig } from 'axios';
import request from '@/common/request';

export const http = {
  get<T>(url: string, config?: AxiosRequestConfig): Promise<T> {
    return request.get(url, config);
  },

  post<T>(
    url: string,
    data?: object,
    config?: AxiosRequestConfig,
  ): Promise<T> {
    return request.post(url, data, config);
  },

  put<T>(
    url: string,
    data?: object,
    config?: AxiosRequestConfig,
  ): Promise<T> {
    return request.put(url, data, config);
  },

  delete<T>(url: string, config?: AxiosRequestConfig): Promise<T> {
    return request.delete(url, config);
  },
};

export type BaseResult<T> = {
  code: number;
  msg: string;
  data?: T;
}

export type BaseData<T> = {
  records: T;
  total: number;
  pageNo: number;
  pageSize: number;
}